<?php

class Notification extends CApplicationComponent
{
    protected $class='', $message='';

    public function getClass()
    {
        if(!$this->class){
            $class=Yii::app()->session['notificationClass'];
            Yii::app()->session['notificationClass']='';
        }else{
            $class=$this->class;
            $this->class='';
        }

        return $class;
    }

    public function getMessage()
    {
        if(!$this->class){
            $message=Yii::app()->session['notificationMessage'];
            Yii::app()->session['notificationMessage']='';
        }else{
            $message=$this->message;
            $this->message='';
        }

        return $message;
    }

    public function setMessage($message)
    {
        $this->class='message';
        $this->message.=$message.' /n';
        Yii::app()->session['notificationClass']=$this->class;
        Yii::app()->session['notificationMessage']=$this->message;
    }

    public function setWarning($message)
    {
        $this->class='warning';
        $this->message.=$message.' /n';
        Yii::app()->session['notificationClass']=$this->class;
        Yii::app()->session['notificationMessage']=$this->message;
    }

    public function setError($message)
    {
        $this->class='error';
        $this->message.=$message.' /n';
        Yii::app()->session['notificationClass']=$this->class;
        Yii::app()->session['notificationMessage']=$this->message;
    }
}